<template>
<div>
    登录页
    <Input v-model="username" placeholder="请输入用户名" />
    <Input v-model="password" placeholder="请输入密码" type="password" />
    <Button type="primary" @click="login">登录</Button>
</div>
</template>

<script>
import Qs from 'qs';
export default {
    data() {
        return {
            username: "admin",
            password: "he1234"
        }
    },
    methods: {
        async login() {
            let data = {
                username: this.username,
                password: this.password,
                clientId: "pc"
            };
            let res = await this.$api.system.login(data)
            if (res.isSucceed) {
                this.$store.commit("setToken", res.rows[0].access_token);

                let user = await this.$api.system.loadUserInfo();
                window.localStorage.setItem("userInfo", JSON.stringify(user.rows[0]));

                this.$router.push({
                    name: 'DomeTest'
                });
            }else{
                this.$Message.error("登录失败:" + res.message);
            }
        }
    },
    created() {

    }
}
</script>

<style lang="less" scoped>

</style>
